package com.nuance.assignment.fileInfo.shared;

import com.google.gwt.core.client.JavaScriptObject;

/**
 * Pure client side JavaScriptObject to parse file information from Json string
 * Uses JSNI for implementation.
 * 
 * @author parag
 *
 */
public class FileJavaScriptObject extends JavaScriptObject {

	protected FileJavaScriptObject() {
	}

	public final native String getName()/*-{
		return this.name
	}-*/;

	public final native String getPath()/*-{
		return this.absolutePath
	}-*/;

	public final native boolean canExecute()/*-{
		return this.canExecute
	}-*/;

	public final native boolean canRead()/*-{
		return this.canRead
	}-*/;

	public final native boolean canWrite()/*-{
		return this.canWrite
	}-*/;

	public final native boolean isFile()/*-{
		return this.file
	}-*/;

	public final native boolean isDirectory()/*-{
		return this.directory
	}-*/;

	public final native boolean isHidden()/*-{
		return this.hidden
	}-*/;

	public final native boolean isAbsolute()/*-{
		return this.absolute
	}-*/;

	public final native double length()/*-{
		return this.length
	}-*/;

	public final native double getLastModified()/*-{
		return this.lastModified
	}-*/;

	public final FileDTO toDto() {
		return new FileDTO(canExecute(), canRead(), canWrite(), isFile(),
				isDirectory(), isHidden(), isAbsolute(),
				(long) getLastModified(), (long) length(), getPath(), getName());
	}

}
